package xj.toolkit.bean.bytebean;

import org.apache.commons.lang3.ArrayUtils;
import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import xj.toolkit.bean.bytebean.core.BeanFieldCodec;
import xj.toolkit.util.DefaultNumberCodecs;

public class AppTest3 {

	public static void main(String[] args) {
		byte[] temperature = DefaultNumberCodecs.getBigEndianNumberCodec().float2Bytes(71.07f, 4);
		byte[] humidity = DefaultNumberCodecs.getBigEndianNumberCodec().float2Bytes(14.9f, 4);

		//
		byte[] data = ArrayUtils.addAll(temperature, humidity);
		
		AbstractApplicationContext ctx = new ClassPathXmlApplicationContext(
				"codec.xml");

		BeanFieldCodec beanCodec = (BeanFieldCodec) ctx.getBean("byteBeanCodec");
		
		System.out.println(beanCodec.decode(beanCodec
				.getDecContextFactory().createDecContext(data,
						TM_JWST_10W1_sensory.class, null, null)).getValue());
		
	}

}
